﻿
<template>
<div class="card-fill layout-padding">
<el-card shadow="hover" class="layout-padding-auto" >
  <WtmSearcher v-model="searchDataProdArchiveData" @search="()=>{getTableDataProdArchiveData();}">
      <el-row>
        <el-col :xs="24" :lg="8" class="mb20">
        <el-form-item ref="ArchiveIdId_FormItem" prop="ArchiveIdId" :label="$t('message.autotrans._Model_ProdArchiveData_ArchiveId')">
            <el-select v-model="searchDataProdArchiveData.ArchiveIdId" clearable>
               <el-option v-for="item in stateProdArchiveData.AllArchiveIds" :key="item.Value" :value="item.Value" :label="item.Text"></el-option>
            </el-select>
        </el-form-item>

        </el-col>
        <el-col :xs="24" :lg="8" class="mb20">
        <el-form-item ref="Sn_FormItem" prop="Sn" :label="$t('message.autotrans._Model_ProdArchiveData_Sn')">
            <el-input v-model="searchDataProdArchiveData.Sn" clearable></el-input>
        </el-form-item>

        </el-col>
        <el-col :xs="24" :lg="8" class="mb20">
        <el-form-item ref="Wo_FormItem" prop="Wo" :label="$t('message.autotrans._Model_ProdArchiveData_Wo')">
            <el-input v-model="searchDataProdArchiveData.Wo" clearable></el-input>
        </el-form-item>

        </el-col>
        <el-col :xs="24" :lg="8" class="mb20">
        <el-form-item ref="ProductId_FormItem" prop="ProductId" :label="$t('message.autotrans._Model_ProdArchiveData_ProductId')">
            <el-input v-model="searchDataProdArchiveData.ProductId" clearable></el-input>
        </el-form-item>

        </el-col>
        <el-col :xs="24" :lg="8" class="mb20">
        <el-form-item ref="ProductCode_FormItem" prop="ProductCode" :label="$t('message.autotrans._Model_ProdArchiveData_ProductCode')">
            <el-input v-model="searchDataProdArchiveData.ProductCode" clearable></el-input>
        </el-form-item>

        </el-col>
        <el-col :xs="24" :lg="8" class="mb20">
        <el-form-item ref="OpId_FormItem" prop="OpId" :label="$t('message.autotrans._Model_ProdArchiveData_OpId')">
            <el-input v-model="searchDataProdArchiveData.OpId" clearable></el-input>
        </el-form-item>

        </el-col>
        <el-col :xs="24" :lg="8" class="mb20">
        <el-form-item ref="OpCode_FormItem" prop="OpCode" :label="$t('message.autotrans._Model_ProdArchiveData_OpCode')">
            <el-input v-model="searchDataProdArchiveData.OpCode" clearable></el-input>
        </el-form-item>

        </el-col>
        <el-col :xs="24" :lg="8" class="mb20">
        <el-form-item ref="DataTag_FormItem" prop="DataTag" :label="$t('message.autotrans._Model_ProdArchiveData_DataTag')">
            <el-input v-model="searchDataProdArchiveData.DataTag" clearable></el-input>
        </el-form-item>

        </el-col>
        <el-col :xs="24" :lg="8" class="mb20">
        <el-form-item ref="DataName_FormItem" prop="DataName" :label="$t('message.autotrans._Model_ProdArchiveData_DataName')">
            <el-input v-model="searchDataProdArchiveData.DataName" clearable></el-input>
        </el-form-item>

        </el-col>
        <el-col :xs="24" :lg="8" class="mb20">
        <el-form-item ref="UpLimit_FormItem" prop="UpLimit" :label="$t('message.autotrans._Model_ProdArchiveData_UpLimit')">
            <el-input v-model="searchDataProdArchiveData.UpLimit" clearable></el-input>
        </el-form-item>

        </el-col>
        <el-col :xs="24" :lg="8" class="mb20">
        <el-form-item ref="DataValue_FormItem" prop="DataValue" :label="$t('message.autotrans._Model_ProdArchiveData_DataValue')">
            <el-input v-model="searchDataProdArchiveData.DataValue" clearable></el-input>
        </el-form-item>

        </el-col>
        <el-col :xs="24" :lg="8" class="mb20">
        <el-form-item ref="LowerLimit_FormItem" prop="LowerLimit" :label="$t('message.autotrans._Model_ProdArchiveData_LowerLimit')">
            <el-input v-model="searchDataProdArchiveData.LowerLimit" clearable></el-input>
        </el-form-item>

        </el-col>
        <el-col :xs="24" :lg="8" class="mb20">
        <el-form-item ref="SetParameter_FormItem" prop="SetParameter" :label="$t('message.autotrans._Model_ProdArchiveData_SetParameter')">
            <el-input v-model="searchDataProdArchiveData.SetParameter" clearable></el-input>
        </el-form-item>

        </el-col>
        <el-col :xs="24" :lg="8" class="mb20">
        <el-form-item ref="CreateTime_FormItem" prop="CreateTime" :label="$t('message.autotrans._Model_ProdArchiveData_CreateTime')">
            <el-date-picker v-model="searchDataProdArchiveData.CreateTime" type='daterange' clearable></el-date-picker>
        </el-form-item>

        </el-col>
        <el-col :xs="24" :lg="8" class="mb20">
        <el-form-item ref="UpdateTime_FormItem" prop="UpdateTime" :label="$t('message.autotrans._Model_ProdArchiveData_UpdateTime')">
            <el-date-picker v-model="searchDataProdArchiveData.UpdateTime" type='daterange' clearable></el-date-picker>
        </el-form-item>

        </el-col>
        <el-col :xs="24" :lg="8" class="mb20">
        <el-form-item ref="CreateBy_FormItem" prop="CreateBy" :label="$t('message.autotrans._Model_ProdArchiveData_CreateBy')">
            <el-input v-model="searchDataProdArchiveData.CreateBy" clearable></el-input>
        </el-form-item>

        </el-col>
        <el-col :xs="24" :lg="8" class="mb20">
        <el-form-item ref="UpdateBy_FormItem" prop="UpdateBy" :label="$t('message.autotrans._Model_ProdArchiveData_UpdateBy')">
            <el-input v-model="searchDataProdArchiveData.UpdateBy" clearable></el-input>
        </el-form-item>

        </el-col>
      </el-row>

  </WtmSearcher>

  <div style="text-align: right;">
      <WtmButton v-auth="'/api/ProductionManagement/ProdArchiveData/Create'" icon='fa fa-plus' type='primary' :button-text="$t('message.autotrans.SysCreate')" @click="OnCreateClick()"/>
    <WtmButton v-auth="'/api/ProductionManagement/ProdArchiveData/BatchDelete'"  icon='fa fa-trash' type='danger' :button-text="$t('message.autotrans.SysDelete')" :confirm="$t('message._system.common.vm.deletetip')" @click="onBatchDelete()"/>
    <WtmButton v-auth="'/api/ProductionManagement/ProdArchiveData/BatchEdit'" icon='fa fa-pencil-square' type='primary' :button-text="$t('message.autotrans.SysBatchEdit')" @click="OnBatchEditClick()"/>
    <WtmButton v-auth="'/api/ProductionManagement/ProdArchiveData/Import'" icon='fa fa-tasks' type='primary' :button-text="$t('message.autotrans.SysImport')" @click="OnImportClick()"/>
    <WtmButton v-auth="'/api/ProductionManagement/ProdArchiveData/ProdArchiveDataExportExcel'"  icon='fa fa-arrow-circle-down' type='primary' :button-text="$t('message.autotrans.SysExport')" @click="onExport()"/>

  </div>
  <WtmTable ref="tableRefProdArchiveData" v-bind="tableDataProdArchiveData">
    <template #operation>
      <el-table-column :label="$t('message._system.common.vm.operate')" width="180">
        <template v-slot="scope">
            <WtmButton v-auth="'/api/ProductionManagement/ProdArchiveData/Edit'" :is-text="true" icon='fa fa-pencil-square' type='warning' :button-text="$t('message.autotrans.SysEdit')" @click="OnEditrowClick(scope.row)"/>
          <WtmButton v-auth="'/api/ProductionManagement/ProdArchiveData/{id}'" :is-text="true" icon='fa fa-info-circle' type='info' :button-text="$t('message.autotrans.Page详情')" @click="OnDetailsrowClick(scope.row)"/>
          <WtmButton v-auth="'/api/ProductionManagement/ProdArchiveData/BatchDelete'"  icon='fa fa-trash' type='danger' :button-text="$t('message.autotrans.SysDelete')" :confirm="$t('message._system.common.vm.deletetip')" :is-text="true"  @click="onDelete(scope.row)"/>

        </template>
      </el-table-column>
    </template>
  </WtmTable>

</el-card>
</div>
</template>


<script setup lang="ts" name="message.autotrans._PageProductionManagementProdArchiveDataIndex;true;Digitalmes.ProductionManagement.Controllers;ProdArchiveData">
import {  ElMessageBox, ElMessage,ElLoading } from 'element-plus';
import { defineAsyncComponent,reactive, ref, getCurrentInstance, onMounted, nextTick } from 'vue';
import { prodarchivedataApi } from '/@/api/productionmanagement/prodarchivedata';
import other from '/@/utils/other';
import fileApi from '/@/api/file';
import { useRouter } from "vue-router";
const ci = getCurrentInstance() as any;

const CreateDialog = defineAsyncComponent(() => import('./create.vue'));
const EditDialog = defineAsyncComponent(() => import('./edit.vue'));
const DetailsDialog = defineAsyncComponent(() => import('./details.vue'));
const BatchEditDialog = defineAsyncComponent(() => import('./batchedit.vue'));
const ImportDialog = defineAsyncComponent(() => import('./import.vue'));

const stateProdArchiveData = reactive({
    
    AllArchiveIds: [] as any[],
});

const searchDataProdArchiveData = ref({
        ArchiveIdId: null,
        Sn: '',
        Wo: '',
        ProductId: null,
        ProductCode: '',
        OpId: null,
        OpCode: '',
        DataTag: '',
        DataName: '',
        UpLimit: null,
        DataValue: '',
        LowerLimit: null,
        SetParameter: '',
        CreateTime: undefined,
        UpdateTime: undefined,
        CreateBy: '',
        UpdateBy: '',
});

// 定义变量内容
const tableRefProdArchiveData = ref();
const tableDataProdArchiveData = ref({
    // 列表数据（必传）
    data: [],
	// 表头内容（必传，注意格式）
	header: [
      {title:ci.proxy.$t('message.autotrans.Page数据源'),key: 'ProdArchiveData_ArchiveId',type: 'text',isCheck: true},
      {title:ci.proxy.$t('message.autotrans.Page追溯码'),key: 'ProdArchiveData_Sn',type: 'text',isCheck: true},
      {title:ci.proxy.$t('message.autotrans.Page工单'),key: 'ProdArchiveData_Wo',type: 'text',isCheck: true},
      {title:ci.proxy.$t('message.autotrans.Page产品号'),key: 'ProdArchiveData_ProductId',type: 'text',isCheck: true},
      {title:ci.proxy.$t('message.autotrans.Page产品名称'),key: 'ProdArchiveData_ProductCode',type: 'text',isCheck: true},
      {title:ci.proxy.$t('message.autotrans.Page工位号'),key: 'ProdArchiveData_OpId',type: 'text',isCheck: true},
      {title:ci.proxy.$t('message.autotrans.Page工位编号'),key: 'ProdArchiveData_OpCode',type: 'text',isCheck: true},
      {title:ci.proxy.$t('message.autotrans.Page变量名称'),key: 'ProdArchiveData_DataTag',type: 'text',isCheck: true},
      {title:ci.proxy.$t('message.autotrans.Page数据名称'),key: 'ProdArchiveData_DataName',type: 'text',isCheck: true},
      {title:ci.proxy.$t('message.autotrans.Page数据上限'),key: 'ProdArchiveData_UpLimit',type: 'text',isCheck: true},
      {title:ci.proxy.$t('message.autotrans.Page数据值'),key: 'ProdArchiveData_DataValue',type: 'text',isCheck: true},
      {title:ci.proxy.$t('message.autotrans.Page数据下限'),key: 'ProdArchiveData_LowerLimit',type: 'text',isCheck: true},
      {title:ci.proxy.$t('message.autotrans.Page设置参数'),key: 'ProdArchiveData_SetParameter',type: 'text',isCheck: true},
      {title:ci.proxy.$t('message.autotrans._AdminCreateTime'),key: 'ProdArchiveData_CreateTime',type: 'text',isCheck: true},
      {title:ci.proxy.$t('message.autotrans._AdminUpdateTime'),key: 'ProdArchiveData_UpdateTime',type: 'text',isCheck: true},
      {title:ci.proxy.$t('message.autotrans._AdminCreateBy'),key: 'ProdArchiveData_CreateBy',type: 'text',isCheck: true},
      {title:ci.proxy.$t('message.autotrans._AdminUpdateBy'),key: 'ProdArchiveData_UpdateBy',type: 'text',isCheck: true},
      {title:ci.proxy.$t('message.autotrans._AdminIsValid'),key: 'ProdArchiveData_IsValid',type: 'switch',isCheck: true},

	],
	// 配置项（必传）
	config: {
        total: 0, // 列表总数
		loading: true, // loading 加载
		isSerialNo: true, // 是否显示表格序号
		isSelection: true, // 是否显示表格多选
		isOperate: true, // 是否显示表格操作栏
	}
});
// 初始化表格数据
const getTableDataProdArchiveData = () => {
    tableRefProdArchiveData.value.doSearch(prodarchivedataApi().search, searchDataProdArchiveData.value)
        .catch((error: any) => {
			other.setFormError(ci, error);
		});
};
const OnCreateClick = () => {
    other.openDialog(ci.proxy.$t('message.autotrans.SysCreate'), CreateDialog, null, getTableDataProdArchiveData)
};

const OnEditrowClick = (row: any) => {
    other.openDialog(ci.proxy.$t('message.autotrans.SysEdit'), EditDialog, row, getTableDataProdArchiveData)
};

const OnDetailsrowClick = (row: any) => {
    other.openDialog(ci.proxy.$t('message.autotrans.Page详情'), DetailsDialog, row, getTableDataProdArchiveData)
};

// 删除
const onDelete = (row: any) => {
    prodarchivedataApi().delete([row.ID]).then(() => { getTableDataProdArchiveData()})
};

const onBatchDelete = () => {
    const selectedrows = tableRefProdArchiveData.value.getSelectedRows();
    const selectedids = selectedrows.map((x: any) => x.ID);
    if (selectedids.length > 0)
      prodarchivedataApi().delete(selectedids).then(() => { getTableDataProdArchiveData()})
    else
      ElMessage.error(ci.proxy.$t('message._system.common.vm.check'));
};

const OnBatchEditClick = () => {
    const selectedrows = tableRefProdArchiveData.value.getSelectedRows();
    const selectedids = selectedrows.map((x: any) => x.ID);
    if (selectedids.length > 0)
      other.openDialog(ci.proxy.$t('message.autotrans.SysBatchEdit'), BatchEditDialog, selectedids, getTableDataProdArchiveData)
    else
      ElMessage.error(ci.proxy.$t('message._system.common.vm.check'));
};

const OnImportClick = () => {
    other.openDialog(ci.proxy.$t('message.autotrans.SysImport'), ImportDialog, null, getTableDataProdArchiveData)
};

const onExport = () => {
	const selected = tableRefProdArchiveData.value.getSelectedRows();
	if (selected.length > 0) {
		prodarchivedataApi().exportById(selected.map((x: any) => x.ID));
	}
	else {
		prodarchivedataApi().export({});
	}
};

// 页面加载时
onMounted(() => {
    
    other.getSelectList('/api/ProductionManagement/ProdArchiveData/GetProdArchives',[],false).then(x=>{stateProdArchiveData.AllArchiveIds = x});
        getTableDataProdArchiveData();

});

// 暴露变量
defineExpose({

});
</script>

<style scoped lang="scss">

</style>

